/**
 * 获得浏览器版本号
 * @return Array['浏览器名称'，'浏览器版本']
 */
export const getBrowserVersion = () => {
  let agent = navigator.userAgent.toLowerCase();
  let arr=[];
  let Browser='';
  let Bversion='';
  let verinNum='';
  //IE
  if(agent.indexOf('msie') > 0){
    let regStr_ie = /msie [\d.]+;/gi ;
    Browser='IE';
    Bversion=''+agent.match(regStr_ie)
  }
  //firefox
  else if(agent.indexOf('firefox') > 0){
    let regStr_ff = /firefox\/[\d.]+/gi;
    Browser='firefox';
    Bversion=''+agent.match(regStr_ff);
  }
  //Chrome
  else if(agent.indexOf('chrome') > 0){
    let regStr_chrome = /chrome\/[\d.]+/gi ;
    Browser='chrome';
    Bversion=''+agent.match(regStr_chrome);
  }
  //Safari
  else if(agent.indexOf('safari') > 0 && agent.indexOf('chrome') < 0){
    let regStr_saf = /version\/[\d.]+/gi ;
    Browser='safari';
    Bversion=''+agent.match(regStr_saf);
  }
  //Opera
  else if(agent.indexOf('opera')>=0){
    let regStr_opera = /version\/[\d.]+/gi ;
    Browser='opera';
    Bversion=''+agent.match(regStr_opera);
  }else{
    let browser=navigator.appName;
    if(browser === 'Netscape'){
      let version=agent.split(';');
      let trim_Version=version[7].replace(/[ ]/g,'');
      let rvStr = trim_Version.match(/[\d\.]/g).toString();
      Bversion = rvStr.replace(/[,]/g,'');
      Browser='IE'
    }
  }
  verinNum=(Bversion+'').replace(/[^0-9.]/ig,'');
  arr.push(Browser);
  arr.push(verinNum);
  return arr;
}
